package com.wss.common.wechat.util.weixin;



import com.wss.common.context.util.SystemConfig;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class AuthorizeLinkOpenManager {
	private static String component_appid = SystemConfig.getComponentAppId();
	private static String pre_auth_code = "AUTHORIZERREFRESHTOKEN";
	private static String domain_name = SystemConfig.getDomainName();
	private static String project_name = SystemConfig.getProjectName();


	//获取公众号授权链接的方法
	public static String getOauthlink(String pre_auth_code){
		try {
			return oauthlinkPrefix + URLEncoder.encode(pre_auth_code,"utf-8") + oauthlinkSuffix;
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}

	//获取代公众号网页授权的方法

		
	//授权链接前缀()
	private static String oauthlinkPrefix= "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="+component_appid+"&pre_auth_code=";
		
	//授权链接后缀
	private static String oauthlinkSuffix= "&redirect_uri=http%3a%2f%2f"+domain_name+"%2f"+project_name+"%2fopen%2fendAuth.do";



	public static  void main(String[] args){
        System.out.println(getOauthlink(pre_auth_code));
		//System.out.println("aa".contains("?"));

    }

}
